<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    request.setAttribute("basePath", basePath);
%>
<%@ include file="/resources/js/easyui/taglibs.jsp" %>
<%@ include file="/resources/js/wechat/_wechatui.jsp" %>
<%@ include file="/resources/js/easyui/_viewJS.jsp" %>
<!DOCTYPE>
<html>
<head>
    <title>${childUser.roleCNName}角色</title>
    <script src="${basePath}resources/js/Jquery-md5.js"></script>
</head>
<body>
<div class="loading"></div>
<!-- header -->
<header>
    <a href="javascript:history.go(-1);" class="top_fh">${childUser.roleCNName}角色</a>
</header>
<!-- header end -->

<div class="page nb_page">
    <div class="my_zzhboxinner">

        <c:forEach items="${childUser.infos}" var="info" varStatus="status">
            <ul style="margin:14px 0px;">
                <li>
                    <div><span>用户名</span><em>${info.username}</em></div>
                </li>
                <li><i>* 系统自动生成，无法更改</i></li>
                <li>
                    <div><span>密码</span><em>******</em><a href="JavaScript:;" class="reset_password" id="${info.userid}">重置密码</a></div>
                </li>
                <li><i>* 系统初始密码默认为：123456</i></li>
                <li><i>* 重置密码，若不需要设置新密码，可直接恢复初始密码。</i></li>
            </ul>
        </c:forEach>

    </div>
</div>

<!-- 修改密码弹窗 -->
<div class="my_passwrodpop ty_pop">
    <div class="popbg"></div>
    <div class="sbname_inner my_zzhresetpsw">
        <em>重置密码</em>

        <p><input id="password" type="text" value="" placeholder="请输入新密码">
            <span style="color:#fe0000; font-size:0.7rem;float:left;opacity:0;">*密码有误，请输入6位数字密码。</span>
        </p>
        <input type="hidden" id="userid" value="">
        <input type="hidden" id="newpassword">

        <div><span>恢复初始密码</span>
            <span id="resetChildUserPassword">确定</span>
            <span>取消</span></div>
        </div>
    </div>
</div>
<!-- 修改密码弹窗 end -->
</body>
</html>

<script type="application/javascript">

    //财务、机修重置密码
    var my_zzhregpsw=/^\d{6}$/;
    var my_zzhresetpsw="";
    var resetpsw=$(".my_zzhresetpsw div span").each(function(my_zzh_index){
        $(this).on("click keydown", function(){
            my_zzhresetpsw=$(".my_zzhresetpsw p input").val();
            if(my_zzh_index==0){
                my_zzhresetpsw="123456";
                $(".my_zzhboxinner ul input").val(my_zzhresetpsw);
                $(".my_zzhresetpsw p input").next().css("opacity","0");
                $(".ty_pop").hide();
            }else if(my_zzh_index==1 && !my_zzhregpsw.test(my_zzhresetpsw)){
                $(".my_zzhresetpsw p input").next().css("opacity","1");
            }else if(my_zzh_index==1 && my_zzhregpsw.test(my_zzhresetpsw)){
                $(".my_zzhboxinner ul input").val(my_zzhresetpsw);
                $(".ty_pop").hide();

                $("#newpassword").val(createPassword(password,password));

                $.ajax({
                    url: '${basePath}wechat/indivdual/resetChildUserPassword',
                    type: 'POST',
                    data: {
                        "userid" : $("#userid").val(),
                        "newpassword" : $("#newpassword").val()
                    },
                    error: function (response) {
                        ViewHelper.func.ajaxWechatErrorMessage(response);
                    },
                    success: function (ret) {
                        if (!ret.result) {
                            alert('温馨提醒:'+ret.info);
                        }else{
                            alert("成功");
                        }
                    }
                });
            }else if(my_zzh_index==2){
                $(".my_zzhresetpsw p input").next().css("opacity","0");
                $(".ty_pop").hide();
            }else{
                $(".my_zzhresetpsw p input").next().css("opacity","1");
            }
        })
    });
    $(".my_zzhresetpsw p input").on("focus", function(){
        $(".my_zzhresetpsw p input").next().css("opacity","0");
    });

    $(".my_zzhboxinner ul li a").on("click" , function(){
        $("#userid").val($(this).attr("id"));
        $(".my_passwrodpop").show();
        $(".my_zzhresetpsw p input").val("");
    });

  /*  $(".reset_password").click(function(){

        $("#password").val($(this).attr("id"));

    });
*/
</script>